﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ComputerArchitecture.Core;
using ComputerArchitecture.Numbers;

namespace ComputerArchitecture.Units.Integers
{
    internal static class FullAdder
    {
        internal static Bit Add(Bit first, Bit second, Bit carryIn, out Bit carryOut)
        {
            ArgumentValidator.NullValidate(first);
            ArgumentValidator.NullValidate(second);
            ArgumentValidator.NullValidate(carryIn);
            Bit result = first ^ second ^ carryIn;
            carryOut = (first & second) ^ (carryIn & (first ^ second));
            return result;
        }
    }

}
